package com.angel.controller;

import com.angel.bean.LearnExp;
import com.angel.bean.VipInfo;
import com.angel.service.LearnExpService;
import com.angel.service.VipInfoService;
import com.angel.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

/**
 * 提交心得
 */
@Controller
@RequestMapping("/sub")
public class SubmitExperienceController {
    @Autowired
    private VipInfoService vipInfoService;

    @Autowired
    private LearnExpService learnExpService;

    @RequestMapping("/submit")
    @ResponseBody
    public Object submit(LearnExp learnExp){
        Map<String,String> map=new HashMap<>();
      //  LearnExp learnExp=new LearnExp();
            try {
                learnExp.setUid(UserUtils.getPrincipal().getUserInfo().getId());
                learnExp.setLearnTime(new Timestamp(System.currentTimeMillis()));
                learnExp.setState(1);
                int result2= learnExpService.insertSelective(learnExp);

                //System.out.println("--成功--");
                if (result2!=0){
                    map.put("emp","true");
                }else {
                    map.put("emp","false");
                }
            }catch (Exception n){
                //System.out.println("--失败--");
                map.put("emp","false");
            }
        return map;
    }
}
